window.addEventListener('load', function () {
    //tab栏切换
    let tabs = document.querySelectorAll('.tab-nav a');
    let tab_pane = document.querySelectorAll('.tab-pane');
    let link = document.querySelector('.link a');
    for (i = 0; i < tabs.length; i++) {
        tabs[i].addEventListener('click', function () {
            document.querySelector('.tab-nav a.active').classList.remove('active');
            this.classList.add('active');
            link.innerHTML = this.innerHTML;
            let num = this.dataset.id;
            console.log(num);
            for (i = 0; i < tab_pane.length; i++) {
                tab_pane[i].style.display = 'none';
            }
            tab_pane[num].style.display = 'block';
        })
    }
    console.log(tabs);
    //登录模块
    let form = document.querySelector('form');
    let agree = document.querySelector('[name=agree]');
    let uname = document.querySelector('[name=username]');
    console.log(location.href);
    form.addEventListener('submit', function (e) {
        e.preventDefault();
        if (!agree.checked) {
            return alert('请你同意用户协议');

        }
        localStorage.setItem('uname', uname.value);
        location.href = 'index.html';
    })
})